﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Elasticsearch.Synchronize.Common.Enum;
using Elasticsearch.Synchronize.Domain.Aggregates.SynchronizeAggregate;
using Elasticsearch.Synchronize.Domain.Events;
using Elasticsearch.Synchronize.Domain.Interface;
using Elasticsearch.Synchronize.DomainEventHandler.Processor;

namespace Elasticsearch.Synchronize.DomainEventHandler.Handler
{
    public class PourDataToElasticsearchEventHandler : MediatR.NotificationHandler<PourDataToElasticsearchDomainEvent>
    {
        private readonly ISynchronizeItemRepository _repository;

        public PourDataToElasticsearchEventHandler(ISynchronizeItemRepository repository)
        {
            _repository = repository;
        }

        protected override void HandleCore(PourDataToElasticsearchDomainEvent notification)
        {
            var item = notification.SynchronizeItem;
            switch (item.Source)
            {
                case DataSource.HexinDbEventJoin:
                    {
                        EventJoinProcessor processor = new EventJoinProcessor(item, _repository);
                        processor.Start();
                    }
                    break;
                case DataSource.ScarmDbContactsContact:
                    break;
                default:
                    break;
            }
        }
    }
}
